package user_forms

import (
	"gopkg.in/go-playground/validator.v9"
	"mime/multipart"
	"rabbit_love/src/model"
	"rabbit_love/src/utils/local"
	"time"
)

/*
LoginRequest 登陆表单
*/
type LoginRequest struct {
	UserName string `json:"userName" validate:"required"`
	PassWord string `json:"passWord" validate:"required"`
}

func (reg *LoginRequest) Validator() error {
	validate := validator.New()
	err := validate.Struct(reg)
	return err
}

type ValType int

const (
	Register ValType = 1
	Forget   ValType = 2
)

/*
RegisterValCodeRequest 获取邮箱验证码
*/
type RegisterValCodeRequest struct {
	Type  ValType `query:"type" validate:"required"`
	Email string  `query:"email" validate:"required,email"`
}

func (reg *RegisterValCodeRequest) Validator() error {
	validate := validator.New()
	err := validate.Struct(reg)
	return err
}

/*
RegisterRequest 注册表单
*/
type RegisterRequest struct {
	Email    string `json:"email" validate:"required,email"`
	NickName string `json:"nickName" validate:"required"`
	UserName string `json:"userName" validate:"required"`
	PassWord string `json:"passWord" validate:"required"`
	Code     string `json:"code" validate:"required"`
}

func (reg *RegisterRequest) Validator() error {
	validate := validator.New()
	err := validate.Struct(reg)
	return err
}

/*
ForgetRequest 忘记密码验证
*/
type ForgetRequest struct {
	Email string `json:"email" validate:"required,email"`
	Code  string `json:"code" validate:"required"`
}

func (reg *ForgetRequest) Validator() error {
	validate := validator.New()
	err := validate.Struct(reg)
	return err
}

/*
ForgetResetRequest 重新设定密码
*/
type ForgetResetRequest struct {
	PassWord string `json:"passWord" validate:"required"`
}

func (reg *ForgetResetRequest) Validator() error {
	validate := validator.New()
	err := validate.Struct(reg)
	return err
}

type Sex string

const (
	Man    Sex = "男孩"
	WoMan  Sex = "女孩"
	Unknow Sex = "未知"
)

type UpdateUserInfoRequest struct {
	NickName string                `form:"nickName"`
	BirthDay local.LocFormTime     `form:"birthDay"`
	Sex      Sex                   `form:"sex"`
	Pic      *multipart.FileHeader `form:"pic"`
}

type GetNomUserInfo struct {
	UserName string `query:"userName" validate:"required"`
}

func (reg *GetNomUserInfo) Validator() error {
	validate := validator.New()
	err := validate.Struct(reg)
	return err
}

/*
SpecLoverRequest 邀请另一半
*/
type SpecLoverRequest struct {
	UserName string `json:"userName"  validate:"required"` // 可以是用户名，也可以是邮箱号
}

func (reg *SpecLoverRequest) Validator() error {
	validate := validator.New()
	err := validate.Struct(reg)
	return err
}

type ApplyInviteRequest struct {
	ControlType model.AcceptType `json:"controlType" validate:"required"`
	InviteId    int              `json:"InviteId" validate:"required"` // 邀请信息的ID
}

func (reg *ApplyInviteRequest) Validator() error {
	validate := validator.New()
	err := validate.Struct(reg)
	return err
}

type UpdateHomeNameRequest struct {
	Name      string    `json:"name"`
	StartTime time.Time `json:"startTime"`
}

type UpdateLoverName struct {
	Name string `json:"name"`
}

func (reg *UpdateLoverName) Validator() error {
	validate := validator.New()
	err := validate.Struct(reg)
	return err
}
